local app = require "app"
local game = app.game.running

local GameObject = require "entities.interfaces.GameObject"
local Client = require "entities.interfaces.Client"
local Player = require "entities.interfaces.Player"

local M = game.kbe.entity("DoudizhuPlayer", GameObject, Client, Player)

function M:__init__()
    GameObject.__init__(self)
    Client.__init__(self)
    Player.__init__(self)
end

function M:set_is_ready(old)
    game.store.room.on_player_ready(self)
end

function M:ready(b)
    if b then
        b = 1
    else
        b = 0
    end
    self:cellCall('ready', b)
end

function M:bid(action_id)
    self:cellCall('bid', action_id)
end

function M:handout(card_ids)
    self:cellCall('handout', card_ids)
end

-------------------------------------------------------------------
function M:req_handout(action_ids, time)
    self.log.debug(string.format("req_handout:%s time:%s", app.dump(action_ids), time))
    game.store.ingame.req_handout({player = self, action_ids = action_ids, time = time})
end

function M:on_deal(card_ids)
    self.log.debug(string.format('on_deal card_ids:%s', app.dump(card_ids)))
    game.store.ingame.on_deal(card_ids)
end

function M:on_game_init(scene)
    self.log.debug(string.format('on_game_init scene:%s', app.dump(scene)))
    game.store.ingame.on_game_init(scene)
end

return M